package com.yc.utils;


import cn.hutool.core.lang.Snowflake;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SnowflakeIdGenerator {

    @Autowired
    private Snowflake snowflake;

    public SnowflakeIdGenerator() {
        // 配置 Snowflake ID Generator
        // 注意 workerId 和 datacenterId 要根据实际情况进行调整
        this.snowflake = new Snowflake(1, 1);  // workerId 和 datacenterId
    }

    public String generateId() {
        // 生成一个唯一 ID
        return String.valueOf(snowflake.nextId());
    }
}

